function [comb_img,hor_com,ver_com,diag1_com,diag2_com] = combination(ver_pyr,hor_pyr,diag1_pyr,diag2_pyr,method,lev1,lev2)
%COMBINATION try to combine the image-details passed to this function by
%different methods 
% 
% Syntax:
%   [comb_img] = combination(varargin)
%   
% Inputs:
%  diag_pyr -  pyramids of diagonal details
%  ver_pyr -   pyramids of vertical details
%  hor_pyr -   pyramids of horizontal details
%  app_pyr -   pyramids of approximated image in different strengths (smoothing levels)
% 
% Outputs:
%    comb_img - the a img_size x img_size array represents the edges in the
%    input image 
%
% Example:
%
% Created on:    2014-01-04 (Mohamed Marouf)
% Last revision: 2014-01-23 (Mohamed Marouf)  

%------------- BEGIN CODE --------------
                
    switch nargin
        case 7
          % Nothing to be done
        otherwise
          error('Invalid number of input args.');
    end
    
    diag2_com=[];    
    [~,img_NO]=size(ver_pyr); % The dimensions of pyramids
    
    if lev2<lev1
      tmp=lev1;
      lev1=lev2;
      lev2=tmp;
    end
    
    %  Normalization to ensure that coefficients used in all details will have
    %  the same relative weights during the suppression
    %for i=1:img_NO
     %ver_pyr{i}=normalize(ver_pyr{i});
     %hor_pyr{i}=normalize(hor_pyr{i});
     %diag_pyr{i}=normalize(diag_pyr{i});
    %end
    
    if  strcmp(method,'mult')  
         %vertical_combination 
         ver_com=ver_pyr{lev1}.*ver_pyr{lev2};
         %horizontal_combination 
         hor_com=hor_pyr{lev1}.*hor_pyr{lev2};
         % diagonal_combination 
         diag1_com=diag1_pyr{lev1}.^2.*diag1_pyr{lev2};  % I added .^2 to diagonal in order to suppress the image valuse~noise from low levels
         
         if ~isempty(diag2_pyr{1})
            diag2_com=diag2_pyr{lev1}.^2.*diag2_pyr{lev2};  % I added .^2 to diagonal in order to suppress the image valuse~noise from low levels
            mag=sqrt(diag1_com.^2+diag2_com.^2+hor_com.^2+ver_com.^2);
         else
            mag=sqrt(diag1_com.^2+hor_com.^2+ver_com.^2);
         end
    end
    
    comb_img=mag;
end
